<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>" />
<jsp:include page="/jsp/common.jsp" />
<jsp:include page="/jsp/formHead.jsp" />
<jsp:include page="/jsp/listHead.jsp" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>resource/css/user.css" />
<script type="text/javascript">
$().ready(function(){

	var dateBox = QDateBox.init("#datePick"),
		districtBox = QDistrictBox.init("#districtPick"),
		checked = "${user.sex }",
		address = "${user.address }",
		birthday = "${user.birthday }";
	dateBox.refresh(new Date());
	districtBox.refresh(QDistrictBox.option.data);

	$("input[type='radio'][value='" + checked + "']").attr("checked", "checked");

	if(birthday){
		dateBox.setValue(birthday);
	}
	
	if(address){

		districtBox.setValue(address);
		$("input[name='addressDetail']").val(address.split(";")[3]);
	}

	$(".updateForm").submit(function(){

		var birthday = dateBox.getValue(),
			disctrict = districtBox.getValue(),
			disctrictDetail = $("input[name='addressDetail']").val();
		
		$("input[name='birthday']").val(birthday == -1 ? null : birthday);
		$("input[name='address']").val(disctrict == -1 ? disctrictDetail : disctrict + ";" + disctrictDetail);
	});
	
	$(".updateForm").validate({
		rules: {
			email: {
				required: true,
				email: true
			},
			address : {
				isDistrict : true
			},
			birthday : {
				isDate : true
			}
		}
	});
});
</script>
</head>
<body>
<jsp:include page="../header.jsp" />
<div class="content">
<div class="bar">
	<jsp:include page="./menu.jsp" />
	<div class="list_div_01 border_radius_3">
		<div class="list_title">个人资料</div>
		<form action="<%=basePath %>user/user_update.do" method="post" class="updateForm">
			<table>
				<tr>
					<th><span class="requiredField">*</span>E-mail:</th>
					<td><input name="email" type="text" class="text" maxlength="200" value="${user.email }"/></td>
				</tr>
				<tr>
					<th>姓名:</th>
					<td><input name="name" type="text" class="text" maxlength="200" value="${user.name }"/></td>
				</tr>
				<tr>
					<th>性别:</th>
					<td>
						<input id="sex_1" type="radio" name="sex" value="1"/><label class="sex_label" for="sex_1">男</label>
						<input id="sex_2" type="radio" name="sex" value="2"/><label class="sex_label" for="sex_2">女</label>
					</td>
				</tr>
				<tr>
					<th>出生日期:</th>
					<td>
						<div id="datePick"></div>
						<input name="birthday" type="hidden"/>
					</td>
				</tr>
				<tr>
					<th>地区:</th>
					<td>
						<div id="districtPick"></div>
						<input name="address" type="hidden" />
					</td>
				</tr>
				<tr>
					<th>地址:</th>
					<td><input name="addressDetail" type="text" class="text" maxlength="200"/></td>
				</tr>
				<tr>
					<th>&nbsp;</th>
					<td>
						<input type="submit" class="submit" value="提交" />
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>
</div>
<jsp:include page="../footer.jsp" />
</body>
</html>